<template>
  <div class="adminyijianfankui">
    <admintop></admintop>
    <div style="padding: 20px 0px;">
      <div style="display: flex; margin-bottom: 20px;">
        <el-input style="width:180px; margin-right: 20px;" v-model="all.shop_name" placeholder="请输入店铺名称"></el-input>
        
        <el-select clearable  style="width:180px; margin-right: 20px;" v-model="all.is_apply"
          placeholder="请选择类型">
          <el-option label="未打标" value="0"></el-option>
          <el-option label="已打标" value="1"></el-option>
        </el-select>
        
        <el-button @click="getlist"  type="danger">搜索</el-button>
      </div>
      <el-table :data="tableData" style="text-align: center;" align="center" border :loading="loading">
        <el-table-column label="店铺名称" align="center">
          <template slot-scope="scope">
            <span>{{ scope.row.shop_name }}</span>
          </template>
        </el-table-column>
        <el-table-column label="绑定时间" align="center">
          <template slot-scope="scope">
            <span>{{ scope.row.updated_at }}</span>
          </template>
        </el-table-column>
        <el-table-column label="绑定商户" align="center">
          <template slot-scope="scope">

            <span>{{ scope.row.name }}</span>
          </template>
        </el-table-column>
        <el-table-column label="打标状态" align="center">
          <template slot-scope="scope">
            <span v-if="scope.row.is_apply == 0">未打标</span>
            <span v-if="scope.row.is_apply == 1">已打标</span>
          </template>
        </el-table-column>
        <el-table-column label="当前cookie" align="center">
          <template slot-scope="scope">
            <span v-if="scope.row.is_cookie == 0">失效</span>
            <span v-if="scope.row.is_cookie == 1">正常</span>
          </template>
        </el-table-column>

        <el-table-column label="操作" align="center">
          <template slot-scope="scope">
            <div style="text-align: center; color: #409EFF; cursor: pointer;" @click="chakan(scope.row)">编辑</div>
          </template>
        </el-table-column>
      </el-table>
      <div class="fenye" style="padding: 20px; text-align: right;">
        <el-pagination background layout="prev, pager, next" @current-change="fanye" :page-size="all.page_size"
          :total="total"></el-pagination>
      </div>
    </div>
    <!-- 查看图片 -->
    <el-dialog title="修改打标状态" center :visible.sync="showimg" width="600px">
      <div>
        <el-radio v-model="fall.is_apply" :label="0">未打标</el-radio>
        <el-radio v-model="fall.is_apply" :label="1">已打标</el-radio>
      </div>
      <span slot="footer" class="dialog-footer">
      	<el-button type="info" @click="showimg = false">取消</el-button>
      	<el-button type="danger" @click="baocun">确认</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
  import admintop from './top.vue';
  import axios from 'axios'
  export default {
    components: {
      admintop
    },
    name: 'adminyijianfankui',
    data() {
      return {
        all: {
          shop_name:"",
          is_apply:"",
          page_size: 20,
          page: 1,
        },
        fall:{
          is_apply:"",
          id:""
        },
        tableData: "",
        total: "",
        loading: true,
        //搜索店铺名称
        imglink:'',
        showimg:false,
        neirong:""
      }
    },
    watch: {

    },
    computed: {

    },
    created() {
      this.getlist()
    },
    methods: {
      chakan:function(item){
        this.fall = {
          is_apply:item.is_apply,
          id:item.id
        }
        this.showimg = true
      },
      //放大图片
      openimg(url){
        console.log(url)
        this.imglink = url
        this.showimg = true
      },
      fanye:function(){
        this.all.page++
        this.getlist()
      },
      baocun:function(){
        axios.post('/api/plan-market/admin/outer_store/update/apply',this.fall)
          .then(response => {
            if (response.data.msg.code == 0) {
              this.$message.success('修改成功');
              this.getlist()
              this.showimg = false
            } else {
              this.$message.error(response.data.msg.info);
            }
          })
      },
      //获取全部
      getlist: function() {
        var that = this

        axios.get('/api/plan-market/admin/outer_store/list',{params:this.all})
          .then(response => {
            if (response.data.msg.code == 0) {
              this.tableData = response.data.data.data
              this.total = response.data.data.total
              this.loading = false
            } else {
              this.$message.error(response.data.msg.info);
            }
          })
      }

    },

  }
</script>

<style scoped>
  img{ max-width: 100%;}
  .adminyijianfankui {
    background: #EAEAEA;
    min-height: 100vh;
    padding: 0px;
  }
  .t_btn_box{
    display: flex;
    justify-content: flex-end;
  }
</style>
